(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.dynaparm.viewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'dynaparmService', '$filter'];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, dynaparmService, $filter) {
		var ctrl = this, dynaparmInfo = $scope.$stateParams.params;
		ctrl.validatorConfig = validatorConfig;
		ctrl.dynaparm = {};
		ctrl.dynaparm.dynaparmSubCat = {};
		dynaparmService.initCtrlFunction(ctrl);
		
		ctrl.init = function() {
			var params = {
				parmId : dynaparmInfo.parmId
			};
			ctrl.innerGridOptions = gridService.createInnerGridOptions($scope, layoutConfig.formConfigs.paramValues.tableConfigs.table);
			ctrl.innerGridOptions.data = 'vm.dynaparm.parmValues';
			ctrl.innerGridOptions.enableRowHeaderSelection = false;

			authService.view(params).then(function(response) {
				ctrl.dynaparm = response.data || dynaparmInfo;
				ctrl.dynaparm.parmValues = ctrl.dynaparm.parmValues || [];
				ctrl.changeServiceCode(ctrl.dynaparm);
				ctrl.changeParmCat(ctrl.dynaparm);
				ctrl.changedSubCat(ctrl.dynaparm);
				ctrl.changeParmTypeSubFun(ctrl.dynaparm);
				ctrl.changeParmValueUitype(ctrl.dynaparm);
				ctrl.layoutConfig = layoutConfig;
			}, angular.noop);
		};
	}
})(angular);